<?
	include('chksession.php');
	session_start();
    $data = file_get_contents("php://input");
    $objData = json_decode($data);
	   $msg='';
	   $user_name= $objData->user_name;
	   $user_id= $objData->user_id;
       $usergroup= $objData->usergroup;
	   $user_pass= $objData->user_pass;
	   $email_id= $objData->email_id;
	   $user_passcnf = $objData->user_passcnf;
	   $created_by=$_SESSION['username'];

		if ($user_passcnf = $user_pass)
		{		
			include('conn.php');
			$sqlc="select count(*) cnt from usermast where user_id='".$user_id."'";
			$resc=mysql_query($sqlc);
			$rowc=mysql_fetch_assoc($resc);
			if (strlen($user_id)>1)
			{
				if($rowc['cnt']==0)
				{
					$sql="insert into usermast(user_name,user_id,usergroup,user_pass,email_id,created_by,create_date)
						values('".$user_name."','".$user_id."','".$usergroup."','".md5($user_pass)."','".$email_id."','".$_SESSION['username']."',sysdate())";
					$res=mysql_query($sql);
					if($res)
						$msg='Record saved successfully';			
				}
				else
				{
						$msg='Record Already Exist';			
				}
			}
			else
			{
				$msg='Blank Name not Allowed';
			}			
		}
		else
		{
			$msg = 'Password and Confirm Password Does Not Match';
		}
	    echo $msg;
?>